<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   <%
		String base = request.getContextPath();
		request.setAttribute("base", base);
	%>
<title>Insert title here</title>
<script type="text/javascript" src="${base}/resources/js/jquery-3.2.1.min.js"></script>

<script type="text/javascript">
	function submit(){
		var uName=$("#Uname").val();
		var uPwd=$("#Upwd").val();
		if(""!=uName || ""!=uPwd){
			$.ajax({
				url:"${base}/login",
				data:{'name':uName,'password':uPwd},
				type:'post',
				success:function(data){
				    if(data=="success"){
				    	location.href="${base}/CommodityController/show";
				    }else{
				    	alert("用户名或密码错误");
				    }
				}		
			})
		}else{
			alert("用户名或密码不能为空");
			return false;
		}
	}
</script>
</head>
<body>
		用户名:<input id="Uname"><br/>
		密码:<input type="password" id="Upwd"><br/>
		<input type="button" value="提交" onclick="return submit()">
		<iframe src="${base}/CommodityController/show"></iframe>
</body>
</html>